<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Config extends Model
{
    use HasFactory;

    protected $guarded = [''];

    public function getValAttribute($val)
    {
        if ($val === 'true') return true;

        elseif ($val === 'false') return false;

        else return intval($val);
    }

    public function setValAttribute($val)
    {
        if ($val === true) $this->attributes['val'] = 'true';

        elseif ($val === false) $this->attributes['val'] = 'false';

        else $this->attributes['val'] = intval($val);
    }
}
